package vars

object VarValTest {
  def main(args: Array[String]): Unit = {
    var dog1 = new Dog
    // dog1 是var1的则 dog1的属性可以变而且dog1本身的引用也可以变
    dog1.name = "marry"
    dog1 = null

    val dog2 = new Dog // 尽量使用val变量，效率高
    // dog2 是val的则 dog2的属性可以变，但是dog2本身引用不可以变
    dog2.name = "harry"
//    dog2 = null error
  }
}

class Dog {
  var name: String = "tom"
}